package com.example.demo.persistence;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class DigestUtil {
    public static String getMD5(byte[] data) throws NoSuchAlgorithmException {
        MessageDigest md = MessageDigest.getInstance("MD5");//获取MD5算法
        md.update(data);//上传数据，加密准备
        byte[] resultBytes = md.digest();//从上传的数据中获取摘要
        String resultString = ByteToString.fromBytesToString(resultBytes);//获取加密结果
        return resultString;
    }
}
